Skip to content

[Dynamic Dashboard] Orders card status filtering #11533

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
May 17, 2024

Conversation

0nko
Copy link
Contributor

@0nko 0nko commented May 16, 2024

Part of #11461, which implements the order filtering by status.

Screen_recording_20240516_212933.webm

To test:

  1. Start the app and make sure the Most recent orders card is selected
  2. Notice the Status filter is initially set to All
  3. Try changing the filter to a different status
  4. Verify the correct orders are being shown

@0nko 0nko added the feature: dashboard Related to home screen project label May 16, 2024
@0nko 0nko added this to the 18.8 milestone May 16, 2024
@0nko 0nko requested a review from hichamboushaba May 16, 2024 19:32
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented May 16, 2024

📲 You can test the changes from this Pull Request in WooCommerce Android by scanning the QR code below to install the corresponding build.

App Name WooCommerce Android
FlavorJalapeno
Build TypeDebug
Commit65542d4
Direct Downloadwoocommerce-prototype-build-pr11533-65542d4.apk

@codecov-commenter
Copy link

codecov-commenter commented May 16, 2024

Codecov Report

Attention: Patch coverage is 0% with 91 lines in your changes are missing coverage. Please review.

Project coverage is 40.41%. Comparing base (293506d) to head (2010826).
Report is 42 commits behind head on trunk.

Current head 2010826 differs from pull request most recent head d825c9e

Please upload reports for the commit d825c9e to get more accurate results.

Files Patch % Lines
...id/ui/dashboard/orders/DashboardOrdersViewModel.kt 0.00% 55 Missing ⚠️
...android/ui/dashboard/orders/DashboardOrdersCard.kt 0.00% 36 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##              trunk   #11533      +/-   ##
============================================
- Coverage     40.45%   40.41%   -0.04%     
  Complexity     5181     5181              
============================================
  Files          1082     1082              
  Lines         62904    62966      +62     
  Branches       8616     8621       +5     
============================================
  Hits          25447    25447              
- Misses        35169    35231      +62     
  Partials       2288     2288              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@hichamboushaba hichamboushaba self-assigned this May 17, 2024
Copy link
Member

@hichamboushaba hichamboushaba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @0nko 💯

I left two np comments, but they are not blocking.

}

private val orderStatusMap = MutableSharedFlow<Map<String, Order.OrderStatus>>(replay = 1)
private val refreshTrigger = MutableSharedFlow<RefreshEvent>(extraBufferCapacity = 1)
private val statusOptions = MutableSharedFlow<List<OrderStatusOption>>(replay = 1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np, given the usage of a SharedFlow here, if we don't have any cached values for the order status options, we won't show emit the UI state until the API call to fetch them is done.

WDYT about replacing the MutableSharedFlow with a MutableStateFlow that starts with listOf(DEFAULT_FILTER_OPTION...)? This way we'll start with all as a single entry at the beginning.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a clever idea 👍

val viewState = selectedFilter.flatMapLatest { status ->
refreshTrigger.map { Pair(status, it) }
}.transformLatest { (filterStatus, refresh) ->
if (refresh.isForced) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

np, wouldn't the check for forced here cause issues on initial load if we don't have any cached orders? I think that as we won't emit anything, we won't have any UI until the orders fetch is done, or I am missing something 🤔

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I added it to avoid the ugly flashing when changing the status filter. I added a check for this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice

@0nko 0nko enabled auto-merge May 17, 2024 11:33
@0nko 0nko changed the title [Dynamic dashboard] Orders card status filtering [Dynamic Dashboard] Orders card status filtering May 17, 2024
@0nko 0nko merged commit 663f191 into trunk May 17, 2024
13 of 15 checks passed
@0nko 0nko deleted the issue/11461-orders-card-filtering branch May 17, 2024 13:38
@0nko 0nko mentioned this pull request May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: dashboard Related to home screen project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants